<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright 2010 Prometheus Consulting
  
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
  
    http://www.apache.org/licenses/LICENSE-2.0
  
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

<xsl:stylesheet version="2.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" 
	xmlns:o="urn:schemas-microsoft-com:office:office" 
	xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" 
	xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" 
	xmlns:v="urn:schemas-microsoft-com:vml" 
	xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" 
	xmlns:w10="urn:schemas-microsoft-com:office:word" 
	xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" 
	xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml"
	xmlns:xlink="http://www.w3.org/1999/xlink" 
	xmlns:dc="http://purl.org/dc/elements/1.1/" 
	xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
	xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
	xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture"
	xmlns:xi="http://www.w3.org/2001/XInclude"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<xsl:param name="images">xxx</xsl:param>
	<xsl:output
		method="xml"
		omit-xml-declaration="no"
		indent="yes"/>
	
	<xsl:template match="/">
	<!-- <xsl:processing-instruction name="xml-stylesheet">type="text/xsl" href="MaduraHTML-1.0.xsl"</xsl:processing-instruction> --> 
	<doc>
	<title>
		<MainTitle><xsl:value-of select="$images"/></MainTitle>
		<SubTitle>Subtitle</SubTitle>
		<Author>Author</Author>
		<Revision>$Revision: 1.5 $</Revision>
		<xi:include>
			<xsl:attribute name="href">
				<xsl:value-of select="$images"/><xsl:text>.log</xsl:text>
			</xsl:attribute>
		</xi:include>
		<references>
			<reference t="Spring Framework" url="http://www.springframework.org" />
			<reference t="slf4j" url="http://www.slf4j.org" />
			<reference t="XInclude" url="http://www.w3.org/TR/xinclude/" />
		</references>
		<reviewers>
			<reviewer complete="true" name="Igor" email="igor@dontgonearthecastle.wa" fullName="Igor"/>
		</reviewers>
	</title>
			<xsl:apply-templates />
	</doc>
	</xsl:template>
	

	<xsl:template match="w:document/w:body">
		<body>
		<xsl:apply-templates/>
		</body>
	</xsl:template>

	<xsl:template match="w:p[/w:pPr/w:pStyle/@w:val='frontpage22point']"/>
	<xsl:template match="w:sdt"/>
	<xsl:template match="w:p[/w:pPr/w:pStyle/@w:val='default']"/>
	<xsl:template match="w:p[/w:pPr/w:pStyle/@w:val='Heading1']">
		<h1>
			<xsl:apply-templates mode="collect"/>
		</h1>
	</xsl:template>
	<xsl:template match="w:p[w:pPr/w:pStyle/@w:val='Heading2']">
		<h2>
			<xsl:apply-templates mode="collect"/>
		</h2>
	</xsl:template>
	<xsl:template match="w:p[w:pPr/w:pStyle/@w:val='Heading3']">
		<h3>
			<xsl:apply-templates mode="collect"/>
		</h3>
	</xsl:template>
	<xsl:template match="w:p[w:pPr/w:pStyle/@w:val='Heading4']">
		<h4>
			<xsl:apply-templates mode="collect"/>
		</h4>
	</xsl:template>
	<xsl:template match="w:p[w:pPr/w:pStyle/@w:val='Heading5']">
		<h5>
			<xsl:apply-templates mode="collect"/>
		</h5>
	</xsl:template>
	<xsl:template match="w:p[w:r/w:drawing]">
		<img height="355px">
			<xsl:attribute name="href">
				<xsl:value-of select="$images"/><xsl:text>/drawingname</xsl:text>
			</xsl:attribute>
			<xsl:attribute name="rid">
				<xsl:apply-templates/>
			</xsl:attribute>
			<xsl:text>drawingtitle</xsl:text>
		</img>
	</xsl:template>
	<xsl:template match="w:r/w:drawing/wp:inline/a:graphic/a:graphicData/pic:pic/pic:blipFill/a:blip">
		<xsl:value-of select="@r:embed"/>
	</xsl:template>
	<!-- 
	<xsl:template match="w:p[w:r/w:object/o:OLEObject]">
		<img height="355px">
			<xsl:attribute name="href">
				<xsl:value-of select="$images"/><xsl:text>/OLEObject</xsl:text>
			</xsl:attribute>
			<xsl:attribute name="rid">
				<xsl:apply-templates/>
			</xsl:attribute>
			<xsl:text>drawingtitle</xsl:text>
		</img>
	</xsl:template>
	 -->
	<xsl:template match="w:p[w:r/w:object/v:shape/v:imagedata]">
		<img height="355px">
			<xsl:attribute name="href">
				<xsl:value-of select="$images"/><xsl:text>/OLEObject</xsl:text>
			</xsl:attribute>
			<xsl:attribute name="rid">
				<xsl:apply-templates mode="rid"/>
			</xsl:attribute>
			<!-- <xsl:text><xsl:apply-templates mode="t"/></xsl:text> -->
		</img>
	</xsl:template>
	<xsl:template match="w:r/w:object/v:shape/v:imagedata" mode="rid">
		<xsl:value-of select="@r:id"/>
	</xsl:template>
	<xsl:template match="w:r/w:object/v:shape/v:imagedata" t="t">
		<xsl:value-of select="@o:title"/>
	</xsl:template>
	<xsl:template match="w:r/w:object/o:OLEObject">
		<xsl:value-of select="@r:id"/>
	</xsl:template>
	<xsl:template match="w:p[w:r/w:t]">
       	<xsl:choose>
       	<xsl:when test="w:pPr/w:pStyle/@w:val='Heading1'">
			<h1>
				<xsl:apply-templates mode="collect"/>
			</h1>
       	</xsl:when>
       	<xsl:when test="w:pPr/w:pStyle/@w:val='Heading2'">
			<h2>
				<xsl:apply-templates mode="collect"/>
			</h2>
       	</xsl:when>
       	<xsl:when test="w:pPr/w:pStyle/@w:val='Heading3'">
			<h3>
				<xsl:apply-templates mode="collect"/>
			</h3>
       	</xsl:when>
       	<xsl:when test="w:pPr/w:pStyle/@w:val='Heading4'">
			<h4>
				<xsl:apply-templates mode="collect"/>
			</h4>
       	</xsl:when>
       	<xsl:when test="w:pPr/w:pStyle/@w:val='Heading5'">
			<h5>
				<xsl:apply-templates mode="collect"/>
			</h5>
       	</xsl:when>
       	<xsl:when test="w:pPr/w:rPr/w:rFonts/@w:cs='Courier New'">
			<code>
				<xsl:apply-templates mode="collect"/>
			</code>
       	</xsl:when>
       	<xsl:when test="w:pPr/w:pStyle/@w:val='Indent1'">
       		<xsl:call-template name="para"/>
       	</xsl:when>
       	<xsl:when test="w:pPr/w:pStyle/@w:val='Caption'">
       		<caption>
				<xsl:apply-templates mode="collect"/>
			</caption>
       	</xsl:when>
       	<xsl:when test="w:pPr/w:pStyle/@w:val='Indent2'">
       		<xsl:call-template name="para"/>
       	</xsl:when>
       	<xsl:when test="w:pPr/w:pStyle/@w:val='Indent3'">
       		<xsl:call-template name="para"/>
       	</xsl:when>
       	<xsl:when test="w:pPr/w:pStyle/@w:val='Indent4'">
       		<xsl:call-template name="para"/>
       	</xsl:when>
       	<xsl:when test="w:pPr/w:pStyle/@w:val='Indent5'">
       		<xsl:call-template name="para"/>
       	</xsl:when>
       	<xsl:when test="w:pPr/w:pStyle/@w:val='BodyText'">
       		<xsl:call-template name="para"/>
       	</xsl:when>
       	<xsl:when test="w:r/w:t/text()">
       		<xsl:call-template name="para"/>
       	</xsl:when>
       	</xsl:choose>
	</xsl:template>
    <xsl:template name="para">
		<p>
		<xsl:if test="w:pPr/w:numPr">
			<xsl:attribute name="list">
				<xsl:value-of select="w:pPr/w:numPr/w:numId/@w:val"/>
			</xsl:attribute>
		</xsl:if>
		<xsl:apply-templates mode="collect"/>
		</p>
	</xsl:template>

	<xsl:template match="w:p" mode="collect">
		<p>
		<xsl:apply-templates mode="collect"/>
		</p>
	</xsl:template>
	<xsl:template match="w:p">
	</xsl:template>
	<xsl:template match="w:r/w:t" mode="collect">
		<xsl:value-of select="text()"/>
	</xsl:template>
	<xsl:template match="w:instrText" mode="collect">
	</xsl:template>
	<xsl:template match="w:r/w:t">
		<p><xsl:value-of select="text()"/></p>
	</xsl:template>
	
	<xsl:template match="w:tbl">
		<table width="16cm">
			<xsl:apply-templates mode="table"/>
		</table>
	</xsl:template>
	<xsl:template match="w:p/w:r/w:t" mode="table">
		<xsl:value-of select="text()"/>
	</xsl:template>

	<xsl:template match="w:tblGrid/w:gridCol" mode="table">
		<tw>3cm</tw>
	</xsl:template>

	<xsl:template match="w:tr" mode="table">
		<tr><xsl:apply-templates mode="table"/></tr>
	</xsl:template>
<!-- 
	<xsl:template match="w:tc" mode="table">
		<td><xsl:apply-templates mode="table"/></td>
	</xsl:template>
 -->
	<xsl:template match="w:tc" mode="table">
		<td><xsl:call-template name="para"/></td>
	</xsl:template>
	
	<!--
	<xsl:template match="w:sdt/w:sdrContent">
		<xsl:apply-templates/>
	</xsl:template>

 
	<xsl:template match="w:p">
		<p>
		<xsl:apply-templates/>
		</p>
	</xsl:template>
	<xsl:template match="w:pPr/w:pStyle">
		<xsl:value-of select="@w:val"/>
	</xsl:template>
 -->

<!-- 

	<xsl:template match="w:r/w:drawing/wp:inline/wp:docPR">
		<img height="355px">
			<xsl:attribute name="href">
				<xsl:apply-templates/>
			</xsl:attribute>
			<xsl:value-of select="@descr"/>
		</img>
	</xsl:template>
	<xsl:template match="w:tbl">
		<table width="16cm">
			<xsl:apply-templates/>
		</table>
	</xsl:template>

	<xsl:template match="w:tblGrid/w:gridCol">
		<tw>3cm</tw>
	</xsl:template>

	<xsl:template match="w:tr">
		<tr><xsl:apply-templates/></tr>
	</xsl:template>

	<xsl:template match="w:tc">
		<td><xsl:apply-templates/></td>
	</xsl:template>
 -->
</xsl:stylesheet>
